<template>
  <common-list>
    <common-table slot="content" v-loading="loading" :data="list">

      <el-table-column label="索引名称" align="left" prop="indexName">
        <template slot-scope="{row}">{{ row.indexName }}</template>
      </el-table-column>

      <el-table-column label="索引前缀" align="left" prop="indexPrefix" show-overflow-tooltip>
        <template slot-scope="{row}">{{ row.indexPrefix || '-' }}</template>
      </el-table-column>
      <el-table-column label="索引类型" align="left" prop="indexType">
        <template slot-scope="{row}">{{ row.indexType || '-' }}</template>
      </el-table-column>

      <el-table-column label="时间格式" align="left" prop="dateFormat">
        <template slot-scope="{row}">{{ row.dateFormat || '-' }}</template>
      </el-table-column>


      <!-- <el-table-column label="组件数据源" align="left" prop="isShow">
        <template slot-scope="{row}">
          <el-switch v-model="row.isShow" :active-value="1" :inactive-value="0">
          </el-switch>
        </template>
      </el-table-column> -->

      <el-table-column label="操作" align="left" width="160">
        <template slot-scope="{row}">
          <el-button type="text" @click="config(row)" v-hasPermi="['system:index:columnlist']">字段配置</el-button>
          <el-button type="text" @click="detail(row)">详情</el-button>
          <!--<el-button  type="text" hasPermi>自动关闭</el-button>-->
        </template>
      </el-table-column>
    </common-table>

    <pagination slot="pagination" v-show="total>0" :total="total" :page.sync="query.pageNum"
                :limit.sync="query.pageSize" @pagination="getList"/>

    <configView ref="configView" v-if="configView" @back="configView = false"/>
    <detailView ref="detailView" v-if="detailView" @back="detailView = false"/>
  </common-list>

</template>

<script>
import configView from './components/configView.vue'
import detailView from './components/detailView.vue'
import { repertory_list } from '@/api/management/echart/repertory'
import BaseList from '@/mixins/BaseList'

export default {
  name: '',
  mixins: [BaseList],
  components: { configView, detailView },
  props: {},
  data() {
    return {
      configView: false,
      detailView: false,
      total: 1, // 总条数
      loading: false, // table 加载中
      list: [{ a: 1 }], // 数据列
      selectionIds: '', // 列表选中数据id
      single: true, // 非单个禁用
      multiple: true, // 非多个禁用
      query: {
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  // 方法
  methods: {
    /**
     * 获取列表
     */
    getList() {
      this.loading = true
      let query = { ...this.query }
      repertory_list(query).then(res => {
        if (res && res.code === 200) {
          this.list = res.rows
          this.total = res.total
        } else {
          this.list = []
          this.total = 0
          this.handleListTips(res)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    detail(row) {
      this.detailView = true
      this.$nextTick(() => {
        this.$refs.detailView.show(row)
      })
    },
    config(row) {
      this.configView = true
      this.$nextTick(() => {
        this.$refs.configView.show(row)
      })

    }
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this.getList()
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
  }
}
</script>
<style lang="scss" scoped>
</style>
